/*****************************************************************************
* File Name: keymatrix.c
*
* Version: 1.0
*
* Description:
* This file contains keyboard button arrays
*
* Note:
* Define DISABLE_KEYBOARD in platform.h to disable keyboard module
* Define KEYBOARD_MULTIMEDIA_SUPPORT in platform.h to enable multimedia support in keyboard module
* Define ENABLE_IR_CODES in platform.h to enable IR support in keyboard module
*
* Owner: MRAO
*
* Related Document:
* None
* 
* Hardware Dependency:
* None
* 
* Code Tested With:
* 1. PSoC Creator 3.1 
* 2. ARM GCC 4.8.4
******************************************************************************
* Copyright (2015), Cypress Semiconductor Corporation.
******************************************************************************
* This software is owned by Cypress Semiconductor Corporation (Cypress) and is
* protected by and subject to worldwide patent protection (United States and
* foreign), United States copyright laws and international treaty provisions.
* Cypress hereby grants to licensee a personal, non-exclusive, non-transferable
* license to copy, use, modify, create derivative works of, and compile the
* Cypress Source Code and derivative works for the sole purpose of creating
* custom software in support of licensee product to be used only in conjunction
* with a Cypress integrated circuit as specified in the applicable agreement.
* Any reproduction, modification, translation, compilation, or representation of
* this software except as specified above is prohibited without the express
* written permission of Cypress.
*
* Disclaimer: CYPRESS MAKES NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, WITH
* REGARD TO THIS MATERIAL, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 
* Cypress reserves the right to make changes without further notice to the
* materials described herein. Cypress does not assume any liability arising out
* of the application or use of any product or circuit described herein. Cypress
* does not authorize its products for use as critical components in life-support
* systems where a malfunction or failure may reasonably be expected to result in
* significant injury to the user. The inclusion of Cypress' product in a life-
* support systems application implies that the manufacturer assumes all risk of
* such use and in doing so indemnifies Cypress against all charges. Use may be
* limited by and subject to the applicable Cypress software license agreement.
*****************************************************************************/
#include "keyboard.h"

#ifndef DISABLE_KEYBOARD

#ifdef DEBUG_MATRIX
const Key keyboard_ScanTable[COLUMNS * ROWS] =
{
    /* Column - 0*/
    {STD_KEY, 0x0001},
    {STD_KEY, 0x0002},
    {STD_KEY, 0x0003},
    /* Column - 1*/
    {STD_KEY, 0x0004},
    {STD_KEY, 0x0005},
    {STD_KEY, 0x0006},
    /* Column - 2*/
    {STD_KEY, 0x0007},
    {STD_KEY, 0x0008},
    {STD_KEY, 0x0009},
};

const uint16 multimedia_Keyboard_ScanTable[] =
{
    0x0000,
};

const uint8 keyboard_Other_ScanTable[] = 
{
    0x0   
};

const uint8 keyboard_Ir_ScanTable[] = 
{
    0x0
};

#else
/*Keyboard lookup table*/
const Key keyboard_ScanTable[COLUMNS * ROWS] = {
    /* Column - 0*/
    {OTHER_KEY, 0x0002},  /* OTHER_KEY  */    {OTHER_KEY, 0x2},  /* audio */       {MULT_KEY, 0x0003}, /* Volume Down*/  {MULT_KEY, 0x0002}, /* Volume Up*/ 
    /* Column - 1*/
    {MULT_KEY, 0x0009},   /* return     */    {MULT_KEY, 0x0007},   /*  home */       {MULT_KEY, 0x0008}, /* menu */        {OTHER_KEY,  0x0005}, /* OTHER_KEY*/
    /* Column - 2*/
    {OTHER_KEY, 0x0004},  /* M          */    {OTHER_KEY,0x0002},   /* OTHER_KEY */   {OTHER_KEY, 0x0002},/*OTHER_KEY */    {OTHER_KEY,  0x0005} /* OTHER_KEY*/
};

/*Multimedia keyboard scan table*/
const uint16 multimedia_Keyboard_ScanTable[] = {
    0x009C, /* Channel Up-------------------0 */
    0x009D, /* Channel Down-----------------1 */
    0x00E9, /* Volume Up--------------------2 */
    0x00EA, /* Volume Down------------------3 */
    0x0087, /* Source-----------------------4 */
    0x0030, /* Power------------------------5 */
    0x009E, /* Return-----------------------6 */
    0x0223, /*KEY_HOMEPAGE -----------------7 */
    0x0040,	/* Menu ------------------------8 */
    0x0224  /*KEY_BACK -------------------- 9 */
};

/*IR key scan table for NEC and Samsung protocols*/
const uint8 keyboard_Ir_ScanTable[] = 
{
#ifndef NEC_PROTOCOL
    /* Column - 0 */
    0x07,            /* Volume Up */   0x12, /* Channel Up */   0x02,            /* On/OFF Power Key */
    
    /* Column - 1 */
    0x0B,            /* Volume Down */ 0x10, /* Channel Down */ INVALID_IR_CODE, /* Left Click */
    
    /* Column - 2 */
    0x01,            /* Source */      INVALID_IR_CODE, /* Pair Button */  INVALID_IR_CODE, /* Right Click */
#else
    /* Column - 0 */
    0x1F, /* Volume Up */   0x49, /* Channel Up */            0x00,            /* On/OFF Power Key */
    /* Column - 1 */
    0x40, /* Volume Down */ 0x4A, /* Channel Down */           INVALID_IR_CODE, /* Left Click */
    /* Column - 2 */
    0x02,  /* Source */     INVALID_IR_CODE, /* Pair Button */ INVALID_IR_CODE /* Right Click */
#endif /*NEC_PROTOCOL*/
};

#define PAIR_BUTTON           0x1
const uint8 keyboard_Other_ScanTable[] = {
    PAIR_BUTTON
};
#endif /* DEBUG_MATRIX */

#endif /* DISABLE_KEYBOARD */
